//
//  MyNavigationController.m
//  QinjinProject
//
//  Created by Michael on 14-9-17.
//  Copyright (c) 2014年 ___Michael___. All rights reserved.
//

#import "MyNavigationController.h"

@interface UIImage()

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

@end

@interface MyNavigationController ()

@end

@implementation MyNavigationController

-(id)initWithRootViewController:(UIViewController *)rootViewController
{
    MyNavigationController* nvc = [super initWithRootViewController:rootViewController];
    if (NSVersionNumber_iOS_7_0)
    {
        self.interactivePopGestureRecognizer.delegate = self;
        self.navigationBar.translucent = YES;
        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bar_alpha_bg.png"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"nav_bar_alpha_bg.png"]];
    }
    else
    {
        self.navigationBar.tintColor = [UIColor whiteColor];
    }
    nvc.delegate = self;
    return nvc;
}

-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (navigationController.viewControllers.count == 1)
        self.currentShowVC = nil;
    else
        self.currentShowVC = viewController;
}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if (gestureRecognizer == self.interactivePopGestureRecognizer)
    {
        return (self.currentShowVC == self.topViewController);
    }
    return YES;
}

@end





